package com.climb.moive.service.impl;

import com.climb.moive.dao.MovieReviewDao;
import com.climb.moive.dao.impl.MovieReviewDaoImpl;
import com.climb.moive.entity.MovieReview;
import com.climb.moive.exception.ApplicationException;
import com.climb.moive.service.MovieReviewService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author Administrator
 * 电影文章业务层实现类
 */
public class MovieReviewServiceImpl implements MovieReviewService {
    MovieReviewDao movieReviewDao=new MovieReviewDaoImpl();
    @Override
    public Integer countMovieReviewNum() {
        try {
            return movieReviewDao.count();
        } catch (SQLException throwables) {
            throw new ApplicationException("计算电影文章出错",throwables);
        }
    }

    @Override
    public Integer countMovieEvaluationNum(Integer memid) {
        try {
            return movieReviewDao.countById(memid);
        } catch (SQLException throwables) {
            throw new ApplicationException("计算电影个人文章出错",throwables);
        }
    }

    @Override
    public void delet(Integer mid) {
        try {
            movieReviewDao.delet(mid);
        } catch (SQLException throwables) {
            throw new ApplicationException("删除电影个人文章出错",throwables);
        }
    }

    @Override
    public void deleteByRid(Integer id) {
        try {
            movieReviewDao.deletByReviewId(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("删除电影个人文章出错",throwables);
        }
    }

    @Override
    public MovieReview findReviewByRid(Integer id) {
        try {
            return movieReviewDao.findRevieByRid(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("查找单个文章出错",throwables);
        }
    }

    @Override
    public List<MovieReview> findAllReview() {
        try {
           return movieReviewDao.findAllMovieReview();
        } catch (SQLException throwables) {
            throw new ApplicationException("查找所有文章出错",throwables);
        }
    }

    @Override
    public List<MovieReview> findReviewByMoiveid(Integer id) {
        try {
            return movieReviewDao.findReviewByMoiveid(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("查找所有文章ByMoiveid出错",throwables);
        }
    }

    @Override
    public void saveMovieReview(MovieReview movieReview) {
        try {
             movieReviewDao.saveMovieReview(movieReview);
        } catch (SQLException throwables) {
            throw new ApplicationException("查找所有文章ByMoiveid出错",throwables);
        }
    }

    @Override
    public List<MovieReview> findReviewByMemberId(Integer id) {
        try {
            return movieReviewDao.findReviewByMemberId(id);
        } catch (SQLException throwables) {
            throw new ApplicationException("查找所有文章ByMoiveid出错",throwables);
        }
    }
}
